{include file="header/index" /}
<div class="container Authority hides" style="display: block;">
    <ul class="clearfix" style="margin:0px" id="MenuShowList">
        <li class="fl {if condition="$action eq 'index'"}current{/if}"><a href="{:url('systemset/index')}">系统设置</a></li>
        <li class="fl {if condition="$action eq 'weixin'"}current{/if}"><a href="{:url('systemset/weixin')}">公众号管理</a></li>
        <li class="fl {if condition="$action eq 'channel'"}current{/if}"><a href="{:url('systemset/channel')}">短信/smtp配置</a></li>
    </ul>
</div>
<div class="container bgwhite">
    {include file="common@public/alert" /}
    <form action="{:url('Systemset/index')}"  enctype="multipart/form-data" method="post" >
    <div class="system-center">
        <h2>默认信息</h2>
        <p class="system-center-box"><label class="system-center-name">系统名称</label><input class="system-center-web" type="text" value="{$data.webtitle|default=''}" name="webtitle"></p>
        <p class="system-center-box"><label class="system-center-name">系统描述</label><input class="system-center-web" type="text" value="{$data.webdesc|default=''}" name="webdesc"></p>
        <div class="system-center-box clearfix">
            <label class="system-center-name fl">系统logo</label>
            <p class="fl system-center-logo clearfix">
                {present name="data.logo" }
                    <img src="{:Config('IMAGES_PATH')}{$data.logo}" id="img_data" width="100" height="40" style="background-color: #1273a3;">
                {else /}
                    <img src="__IMG__/logo_up.png" id="img_data" width="100" height="40">
                {/present}
                <input type="file" class="fl"  onchange="showlog()" id="logo" name="logo" />
                <span class="mt10">建议尺寸(100*40)</span>
            </p>
        </div>
        <div class="system-center-box system-center-address clearfix">
            <label class="system-center-name fl">默认地区</label>
            <p class="fl">
                <select id="province" name="province">
                    <option value="0">--请选择省份--</option>
                </select>
                <select id="city" name="city">
                    <option value="0">--请选择城市--</option>
                </select>
                <select id="area" name="area">
                    <option value="0">--请选择区/县--</option>
                </select>
                <input type="text" value="{$data.address|default=''}" name="address" placeholder="请输入详细地址">
            </p>
        </div>
    </div>

    <div class="system-center">
        <h2>安全与调试</h2>
        <!--
        <p class="system-center-box">
            <label class="system-center-name">XXXX</label>
            <input class="system-center-web" type="text" value="" name="" >
            <span class="col-red ml20">*</span>
        </p>
        -->
        <div class="system-center-box">
            <label class="system-center-name">清空缓存</label>
            <button class="system-center-empty " onclick="clearrunftime(this)">清空</button>
        </div>
        <p class="system-center-box">
            <label class="system-center-name">是否启用验证码</label>
            <input type="hidden" name="iscode" value="">
            <button type="button" class="system-center-open {if condition="$data.iscode eq 1"}system-center-current{/if}" onclick="switchBtn(this,1)">打开</button>
            <button type="button" class="system-center-shut {if condition="$data.iscode eq 0"}system-center-current{/if}"  onclick="switchBtn(this,0)">关闭</button>
        </p>

    </div>

    <div class="system-center">
        <h2>其它设置</h2>
        <!--
        <p class="system-center-box">
            <label class="system-center-name">合同提醒时间</label>
            <input class="system-center-txt" type="text" value="" name="" placeholder="30">
            <span class=" ml10">天</span>
        </p>
        -->
        <p class="system-center-box">
            <label class="system-center-name">合同换芯周期</label>
            <input class="system-center-txt" type="text" value="{$data.hxcycle|default='30'}" name="hxcycle" >
            <span class=" ml10">月</span>
        </p>
        <p class="system-center-box">
            <label class="system-center-name">合同续费周期</label>
            <input class="system-center-txt" type="text" value="{$data.xfcycle|default='30'}" name="xfcycle" >
            <span class=" ml10">年</span>
        </p>
        <p class="system-center-box">
            <label class="system-center-name">列表数</label>
            <input class="system-center-txt" type="text" value="{$data.pagesize|default='15'}" name="pagesize" >
            <span class=" ml10">条</span>
        </p>
    </div>

    <p class="system-bottom-btn">
        <button type="submit" class="system-Determine">确定</button>
        <button type="button" class="system-Reset">重置</button>
    </p>
    </form>
</div>
<script>
    //地区三级联动
    $(function() {
        var province = {$data.province};
        var cityid = {$data.city};
        var areaid = {$data.area};
        $.post("{:url('Three/province')}",{suggest:1},function(result){
            console.info(result);
            $.each(result, function(k, p) {
                if(p.id==province){
                    var option = "<option selected='selected' value='" +  p.id+ "'  title='"+p.id+"'>" + p.area_name + "</option>";
                }else{
                    var option = "<option value='" +  p.id+ "'  title='"+p.id+"'>" + p.area_name + "</option>";
                }

                $("#province").append(option);
            });
        });
        $.post("{:url('Three/city')}",{parent_id:province},function(city){
            $.each(city, function(k, p) {
                    if(p.id==cityid) {
                        var option = "<option selected='selected' value='" + p.id + "' title='" + p.id + "'>" + p.area_name + "</option>";
                    }else{
                        var option = "<option value='" + p.id + "' title='" + p.id + "'>" + p.area_name + "</option>";
                    }
                    $("#city").append(option);
            });
        });
        $.post("{:url('Three/areas')}",{city_id:cityid},function(area){
            $.each(area, function(k, p) {
                if(p.id==areaid) {
                    var option = "<option  selected='selected' value='" + p.id+ "' title='"+p.id+"'>" + p.area_name + "</option>";
                }else{
                    var option = "<option value='" + p.id+ "' title='"+p.id+"'>" + p.area_name + "</option>";
                }
                $("#area").append(option);
            });
        });




        $("#province").change(function() {
            var name =  $(this).find("option:selected").attr("title");
            console.info(name);
            $("#city option:gt(0)").remove();
            $("#area option:gt(0)").remove();
            $.post("{:url('Three/city')}",{parent_id:name},function(city){
                $.each(city, function(k, p) {
                    if(p.parent_id == name) {
                        var option = "<option value='" + p.id + "' title='"+ p.id+"'>" + p.area_name + "</option>";
                        $("#city").append(option);
                    }
                });
            });


        });

        $("#city").change(function() {
            var name =  $(this).find("option:selected").attr("title");;
            $("#area option:gt(0)").remove();
            $.post("{:url('Three/areas')}",{city_id:name},function(area){
                $.each(area, function(k, p) {
                    if(p.parent_id == name) {
                        var option = "<option value='" + p.id+ "' title='"+p.id+"'>" + p.area_name + "</option>";
                        $("#area").append(option);
                    }
                });
            });
        });
    });

    //清理缓存
    function clearrunftime(obj){
        $(obj).addClass('system-center-current');
        layer.confirm('确定要清空缓存?', {
            btn: ['确定','取消'] //按钮
        }, function(){
            $.post("{:url('Systemset/cleanruntime')}",{suggest:1},function(result){
                layer.msg(result.msg, {icon: 1,time: 500,});
                $(obj).removeClass('system-center-current');
            });
        }, function(){
            $(obj).removeClass('system-center-current');
        });
    }


    //调试模式是否打开按钮
    function switchBtn(obj,i){
        $(obj).addClass("system-center-current");
        $(obj).siblings().removeClass("system-center-current");
        $("input[name='iscode']").val(i);
    }

    /**
     * 图片显示
     */
    function showlog() {
        var file = document.getElementById("logo").files[0];
        var reader = new FileReader();
        reader.onload = function(e) {
            img_data.src = this.result;
        };
        reader.readAsDataURL(file); //Base64
    }
</script>
</body>

</html>